package cheqex.dao;

import org.apache.torque.util.Criteria;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
/*
Collection Check Peer:
addCollectionCheck - adds deposit check data
editCollectionCheck - edit deposit check data 
deleteCollectionCheck -  delete deposit check data
*/

public class CollectionCheckPeer extends cheqex.dao.BaseCollectionCheckPeer
{
	public static boolean addCollectionCheck(String prNumber, int amt, String particulars, java.sql.Date prDate, int id){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCheckPeer.PRNUMBER, prNumber);
		criteria.add(CollectionCheckPeer.AMOUNT, amt);
		criteria.add(CollectionCheckPeer.PARTICULARS, particulars);
		criteria.add(CollectionCheckPeer.PRDATE, prDate);
		criteria.add(CollectionCheckPeer.WEEKID, id);
		
		try{
			CollectionCheckPeer.doInsert(criteria);
			return true;
		}catch (Exception e) { 
			e.printStackTrace(); 
			return false;
		}
	}
	
	public static List<CollectionCheck> retrieveAllCollectionCheck(java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCheckPeer.PRDATE,date);
		
		try{
			return (List<CollectionCheck>)CollectionCheckPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<CollectionCheck>();
		}
	}
	
	public static List<CollectionCheck> retrieveWeekCollectionCheck(int id){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCheckPeer.WEEKID,id);
		
		try{
			return (List<CollectionCheck>)CollectionCheckPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<CollectionCheck>();
		}
	}
	
	public static boolean editCollectionCheck(String prNumber, int amt, String particulars, java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCheckPeer.AMOUNT, amt);
		criteria.add(CollectionCheckPeer.PARTICULARS, particulars);
		
		Criteria scriteria = new Criteria();
		scriteria.add(CollectionCheckPeer.PRNUMBER, prNumber);
		scriteria.add(CollectionCheckPeer.PRDATE, date);
		try{
			CollectionCheckPeer.doUpdate(scriteria, criteria);
			return true;
		}catch (Exception e) { 
			e.printStackTrace(); 
			return false;
		}
	}
	
	public static boolean deleteCollectionCheck(String prNumber, java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCheckPeer.PRNUMBER, prNumber);
		criteria.add(CollectionCheckPeer.PRDATE, date);
		try{
			CollectionCheckPeer.doDelete(criteria);
			return true;
		}catch (Exception e){
			e.printStackTrace();
			return false;
		}
	}
	
	public static CollectionCheck getPR(String prNumber, java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCheckPeer.PRNUMBER, prNumber);
		criteria.add(CollectionCheckPeer.PRDATE, date);
		try{
			if(CollectionCheckPeer.doSelect(criteria)!=null)
				return (CollectionCheck)CollectionCheckPeer.doSelect(criteria).get(0);
			else return null;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	
	public static List<CollectionCheck> getData(String number){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCheckPeer.PRNUMBER, number);
		
		try{
			return (List<CollectionCheck>)CollectionCheckPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return null;
			}
	}
	
	public static List<CollectionCheck> filterCollectionCheckByPRNo(String prNumber){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCheckPeer.PRNUMBER, prNumber);
		
		try{
			return (List<CollectionCheck>)CollectionCheckPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<CollectionCheck>();
		}
	}
	
	public static List<CollectionCheck> filterCollectionCheckByPRDate(java.sql.Date prDate){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCheckPeer.PRDATE, prDate);
		
		try{
			return (List<CollectionCheck>)CollectionCheckPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<CollectionCheck>();
		}
	}
	
	public static List<CollectionCheck> searchCollectionCheckParticular(String prNumber, java.sql.Date prDate){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCheckPeer.PRNUMBER, prNumber);
		criteria.add(CollectionCheckPeer.PRDATE, prDate);
		
		try{
			return (List<CollectionCheck>)CollectionCheckPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<CollectionCheck>();
		}
	}

}
